<?php

/**
 * Class for generating empty row for specified peer
 *
 */
class RowFactory 
{
	/**
	 * Factory method
	 *
	 * @param string $peer
	 * @param array $data
	 * @return Db_Row
	 */
	public static function factory($peer, array $data)
	{
		try {
			$peer = call_user_func(array($peer, 'getInstance'));
			$row = $peer->createRow();
			if ($data) {
				$row->setFromArray($data);
			}
			return $row;
		} catch (Exception $e) {
			return null;
		}
	}
}